package model.model01.demo02.utils;

public class Operate {

    public static double GetResult(String number1, String operate, String number2) {
        double result = 0.0;
        switch (operate) {
            case "+" : result = Double.parseDouble(number1) + Double.parseDouble(number2); break;
            case "-" : result = Double.parseDouble(number1) - Double.parseDouble(number2); break;
            case "*" : result = Double.parseDouble(number1) * Double.parseDouble(number2); break;
            case "/" :
                if ("0".equals(number2)) {
                    System.out.println("除数不能为0");
                    break;
                }
                result = Double.parseDouble(number1) / Double.parseDouble(number2);
                break;
            default: System.out.println("暂不支持运算符");
        }
        return result;
    }
}
